package com.cloud.order;

import com.alibaba.cloud.nacos.annotation.NacosConfig;
import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.cloud.order.config.OrderConfigProperties;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;

import java.util.List;

/**
 * @author 韩先楚
 */
@SpringBootTest(classes = OrderApplication01.class)
public class OrderApplicationText {

    @Autowired
    private DiscoveryClient discoveryClient;
    @Test
    public void nacoscoverytest() {
        for (String serviceId : discoveryClient.getServices()
        ) {
            System.out.println(serviceId);
            List<ServiceInstance> instances = discoveryClient.getInstances(serviceId);
            for (ServiceInstance instance : instances) {
                System.out.println(instance.getServiceId() + "\t" + instance.getHost() + "\t" + instance.getPort() + "\t" + instance.getUri());
            }
        }
    }

@Autowired
private OrderConfigProperties orderConfigProperties;

    @Test
    public void nacosconfigtest() {
        System.out.println(orderConfigProperties.getDatabase());
        System.out.println(orderConfigProperties.getTimeout());
    }
}
